package com.fs.base.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.fs.base.pojo.Role;
import com.fs.base.pojo.UserRole;

/**
 * @author TiddlerCJ
 */
public interface UserRoleRepository extends JpaRepository<UserRole,String>, JpaSpecificationExecutor<UserRole>{
	@Transactional
	void deleteByUserId(String userId);
	
	List<UserRole> findByUserId(String userId);
	
	@Query("select r from Role r where r.id in ( select ur.roleId from UserRole ur where ur.userId = ?1 )")
	List<Role> findRoleByUserId(String userId);
	
}
